

package com.zmks.jkgj.xuexiao.controller;




import java.util.Date;
import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import com.zmks.jkgj.core.controller.ABaseController;
import com.zmks.jkgj.core.resp.Resp;
import com.zmks.jkgj.xuexiao.resp.WebResp;
import com.zmks.jkgj.xuexiao.service.ICrctObjSchoolService;
import com.zmks.jkgj.xuexiao.service.ICrctObjTeacherService;
import com.zmks.jkgj.xuexiao.vo.CrctObjSchoolVO;
import com.zmks.jkgj.xuexiao.vo.CrctObjStudentVO;
import com.zmks.jkgj.xuexiao.vo.CrctObjTeacherVO;

@Controller
public class CrctObjSchoolController extends ABaseController {
	
	@Autowired
	
	private ICrctObjSchoolService crctObjSchoolService;	
     @Autowired
	
	private ICrctObjTeacherService crctObjTeacherService;


	 //查询用户
	@RequestMapping("/get_CrctObjSchool_list")
	@ResponseBody
	public Resp get_CrctObjSchool_list( Integer pageIndex,
			Integer pageSize,HttpServletRequest request) {
		WebResp 	webResp = new WebResp();
	   CrctObjSchoolVO crctObjSchoolVO=new  CrctObjSchoolVO();
		webResp.setData(crctObjSchoolService.getList(crctObjSchoolVO));
		webResp.setTotalCount(crctObjSchoolService.getCount(crctObjSchoolVO));
		return webResp;
	}
	 //增加学校
	@RequestMapping("/save_CrctObjSchool")
	@ResponseBody
	public Resp save_CrctObjSchool(String  name,String address ,String contact,String web_site,String student_num,HttpServletRequest request) {
		WebResp 	webResp = new WebResp();
	   CrctObjSchoolVO crctObjSchoolVO=new  CrctObjSchoolVO();
	   crctObjSchoolVO.setName(name);
	   crctObjSchoolVO.setAddress(address);
	   crctObjSchoolVO.setContact(contact);
	   crctObjSchoolVO.setStudent_num(student_num);
       crctObjSchoolVO.setWeb_site(web_site);
	   crctObjSchoolVO.setCreate_date(new Date());
	   crctObjSchoolVO.setOid(crctObjSchoolVO.getId());
	   crctObjSchoolService.save(crctObjSchoolVO);
		return webResp;
	}
	
	 //增加学校和教务管理员
	@RequestMapping("/save_CrctObjSchool_jiaowu")
	@ResponseBody
	public Resp save_CrctObjSchool_jiaowu(String  name,String address ,String contact,String web_site,String student_num,
			String jiaowu_name,
			String jiaowu_shouji,
			String jiaowu_card,
			String jiaowu_email,
			
			HttpServletRequest request) {
		WebResp 	webResp = new WebResp();
	   CrctObjSchoolVO crctObjSchoolVO=new  CrctObjSchoolVO();
	   crctObjSchoolVO.setName(name);
	   crctObjSchoolVO.setAddress(address);
	   crctObjSchoolVO.setContact(contact);
	   crctObjSchoolVO.setStudent_num(student_num);
       crctObjSchoolVO.setWeb_site(web_site);
	   crctObjSchoolVO.setCreate_date(new Date());
	   crctObjSchoolVO.setOid(crctObjSchoolVO.getId());
	   CrctObjSchoolVO crctObjSchoolVO2=crctObjSchoolService.save(crctObjSchoolVO);
	   CrctObjTeacherVO crctObjTeacherVO=new CrctObjTeacherVO();
	   crctObjTeacherVO.setSchool_oid(crctObjSchoolVO2.getOid());
	   crctObjTeacherVO.setName(jiaowu_name);
	   crctObjTeacherVO.setEmail(jiaowu_email);
	   crctObjTeacherVO.setMobile(jiaowu_shouji);
	   crctObjTeacherVO.setCard_id(jiaowu_card);
	   crctObjTeacherVO.setJob("admin");
	   crctObjTeacherService.save(crctObjTeacherVO);
		return webResp;
	}
	 //删除学校
	@RequestMapping("/remove_CrctObjSchool")
	@ResponseBody
	public Resp remove_CrctObjSchool( Long id,HttpServletRequest request) {
		WebResp 	webResp = new WebResp();
		crctObjSchoolService.remove(id);

		return webResp;
	}
	 //当前登录
	@RequestMapping("/getcurrent_CrctObjSchool")
	@ResponseBody
	public Resp getcurrent_CrctObjSchool( HttpServletRequest request) {
		request.getSession();
		WebResp 	webResp = new WebResp();
		//CrctObjSchoolVO crctObjSchoolVO=	crctObjSchoolService.get(id);
		 HashMap map=new HashMap();
		 map.put("id", "2");
		 map.put("name", "第一中学");
	     webResp.setData(map);
         return webResp;
	}
	
	
	

}
